home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 104 / MacAddict_104_2005-04.iso / Software / Internet & Communication / WordPress 1.2.2 freeware.dmg / wordpress / wp-admin / moderation.php < prev    next >
Encoding:
PHP Script  |  2004-05-08  |  5.7 KB  |  186 lines

  1. <?php
  2. require_once('../wp-includes/wp-l10n.php');
  3.  
  4. $title = __('Moderate comments');
  5. $parent_file = 'edit.php';
  6. /* <Moderation> */
  7.  
  8. function add_magic_quotes($array) {
  9.     foreach ($array as $k => $v) {
  10.         if (is_array($v)) {
  11.             $array[$k] = add_magic_quotes($v);
  12.         } else {
  13.             $array[$k] = addslashes($v);
  14.         }
  15.     }
  16.     return $array;
  17.  
  18. if (!get_magic_quotes_gpc()) {
  19.     $_GET    = add_magic_quotes($_GET);
  20.     $_POST   = add_magic_quotes($_POST);
  21.     $_COOKIE = add_magic_quotes($_COOKIE);
  22. }
  23.  
  24. $wpvarstoreset = array('action','item_ignored','item_deleted','item_approved');
  25. for ($i=0; $i<count($wpvarstoreset); $i += 1) {
  26.     $wpvar = $wpvarstoreset[$i];
  27.     if (!isset($$wpvar)) {
  28.         if (empty($_POST["$wpvar"])) {
  29.             if (empty($_GET["$wpvar"])) {
  30.                 $$wpvar = '';
  31.             } else {
  32.                 $$wpvar = $_GET["$wpvar"];
  33.             }
  34.         } else {
  35.             $$wpvar = $_POST["$wpvar"];
  36.         }
  37.     }
  38. }
  39.  
  40. $comment = array();
  41. if (isset($_POST["comment"])) {
  42.     foreach ($_POST["comment"] as $k => $v) {
  43.         $comment[intval($k)] = $v;
  44.     }
  45. }
  46.  
  47. switch($action) {
  48.  
  49. case 'update':
  50.  
  51.     $standalone = 1;
  52.     require_once('admin-header.php');
  53.  
  54.     if ($user_level < 3) {
  55.         die(__('<p>Your level is not high enough to moderate comments.</p>'));
  56.     }
  57.  
  58.     $item_ignored = 0;
  59.     $item_deleted = 0;
  60.     $item_approved = 0;
  61.     
  62.     foreach($comment as $key => $value) {
  63.         switch($value) {
  64.             case 'later':
  65.                 // do nothing with that comment
  66.                 // wp_set_comment_status($key, "hold");
  67.                 ++$item_ignored;
  68.                 break;
  69.             
  70.             case 'delete':
  71.                 wp_set_comment_status($key, 'delete');
  72.                 ++$item_deleted;
  73.                 break;
  74.             
  75.             case 'approve':
  76.                 wp_set_comment_status($key, 'approve');
  77.                 if (get_settings('comments_notify') == true) {
  78.                     wp_notify_postauthor($key);
  79.                 }
  80.                 ++$item_approved;
  81.                 break;
  82.         }
  83.     }
  84.  
  85.     $file = basename(__FILE__);
  86.     header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved");
  87.     exit();
  88.  
  89. break;
  90.  
  91. default:
  92.  
  93.     require_once('admin-header.php');
  94.  
  95.     if ($user_level <= 3) {
  96.         die(__('<p>Your level is not high enough to moderate comments.</p>'));
  97.     }
  98. ?>
  99. <ul id="adminmenu2">
  100.        <li><a href="edit.php"> <?php _e('Posts') ?></a></li>
  101.         <li><a href="edit-comments.php"> <?php _e('Comments') ?></a></li>
  102.     <li class="last"><a href="moderation.php" class="current"><?php _e('Awaiting Moderation') ?></a></li>
  103. </ul>
  104. <?php
  105.  
  106. if (isset($deleted) || isset($approved) || isset($ignored)) {
  107.     echo "<div class='updated'>\n<p>";
  108.     if ($approved) {
  109.         if ('1' == $approved) {
  110.          echo __("1 comment approved <br />") . "\n";
  111.         } else {
  112.          echo sprintf(__("%s comments approved <br />"), $approved) . "\n";
  113.         }
  114.     }
  115.     if ($deleted) {
  116.         if ('1' == $deleted) {
  117.         echo __("1 comment deleted <br />") . "\n";
  118.         } else {
  119.         echo sprintf(__("%s comments deleted <br />"), $deleted) . "\n";
  120.         }
  121.     }
  122.     if ($ignored) {
  123.         if ('1' == $ignored) {
  124.         echo __("1 comment unchanged <br />") . "\n";
  125.         } else {
  126.         echo sprintf(__("%s comments unchanged <br />"), $ignored) . "\n";
  127.         }
  128.     }
  129.     echo "</p></div>\n";
  130. }
  131.  
  132. ?>
  133.     
  134. <div class="wrap">
  135. <?php
  136. $comments = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_approved = '0'");
  137.  
  138. if ($comments) {
  139.     // list all comments that are waiting for approval
  140.     $file = basename(__FILE__);
  141. ?>
  142.     <?php _e('<p>The following comments are in the moderation queue:</p>') ?>
  143.     <form name="approval" action="moderation.php" method="post">
  144.     <input type="hidden" name="action" value="update" />
  145.     <ol id="comments">
  146. <?php
  147.     foreach($comments as $comment) {
  148.     $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
  149.     $post_title = $wpdb->get_var("SELECT post_title FROM $tableposts WHERE ID='$comment->comment_post_ID'");
  150.     
  151.     echo "\n\t<li id='comment-$comment->comment_ID'>"; 
  152.     ?>
  153.             <p><strong><?php _e('Name:') ?></strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('Email:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_email) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
  154. <?php comment_text() ?>
  155. <p><?php
  156. echo "<a href=\"post.php?action=editcomment&comment=".$comment->comment_ID."\">" . __('Edit') . "</a>";
  157. echo " | <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\">" . __('Delete just this comment') . "</a> | "; ?><?php _e('Bulk action:') ?>
  158.     <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-approve" value="approve" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-approve"><?php _e('Approve') ?></label>
  159.     <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-delete" value="delete" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-delete"><?php _e('Delete') ?></label>
  160.     <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-nothing" value="later" checked="checked" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-nothing"><?php _e('Do nothing') ?></label>
  161.  
  162.     </li>
  163. <?php
  164.     }
  165. ?>
  166.     </ol>
  167.     <p class="submit"><input type="submit" name="submit" value="<?php _e('Moderate Comments »') ?>" /></p>
  168.     </form>
  169. <?php
  170. } else {
  171.     // nothing to approve
  172.     echo __("<p>Currently there are no comments to be approved.</p>") . "\n";
  173. }
  174. ?>
  175.  
  176. </div>
  177.  
  178. <?php
  179.  
  180. break;
  181. }
  182.  
  183. /* </Template> */
  184. include("admin-footer.php") ?>
  185.